<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCouponRuleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupon_rule', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->timestamps();

            $table->integer('limit')->unsigned()->default(1)->comment('每人限领数量');
            $table->integer('expiration_date_type')->unsigned()->default(1)->comment('有效期类型，1是固定日期，2是领到劵的N天开始N天内有效');

            $table->timestamp('start_time')->nullable()->comment('固定时间，开始时间');
            $table->timestamp('end_time')->nullable()->comment('固定时间，结束时间');

            $table->integer('until_days')->unsigned()->comment('领劵后多少天生效，0为立即生效');

            $table->integer('expiration_days')->default(1)->unsigned()->comment('领劵后生效多少天');

            $table->integer('goods_type')->unsigned()->comment('可用商品类型，1是指定商品（关联优惠券指定商品表），2是指定分类（关联优惠券分类表），3是所有商品');

        });

        DB::statement("ALTER TABLE `coupon_rule` COMMENT='优惠券规则表'");//表注释

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupon_rule');
    }
}
